package com.sketch.commom.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.sketch.commom.config.properties.AliProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ali配置
 *
 * @author Michelle.Chung
 */
@EnableConfigurationProperties(AliProperties.class)
@Configuration
public class AliClientConfig {

    @Bean
    //@ConditionalOnProperty(value = "mail.enabled", havingValue = "true")
    public AlipayClient alipayClient(AliProperties properties) {
        return  new DefaultAlipayClient(properties.getUrl(),
                properties.getAppId(),
                properties.getPrivateKey(), "json", properties.getCharset(),
                properties.getPublicKey(), properties.getSignType());
    }

}
